package com.ruoyi.pressure.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.pressure.dto.DblcAbnormalDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.pressure.mapper.KyLaneDblcAbnormalMapper;
import com.ruoyi.pressure.domain.KyLaneDblcAbnormal;
import com.ruoyi.pressure.service.IKyLaneDblcAbnormalService;

/**
 * 顶 板离层测点异常信息数据项说明Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@Service
public class KyLaneDblcAbnormalServiceImpl extends ServiceImpl<KyLaneDblcAbnormalMapper, KyLaneDblcAbnormal> implements IKyLaneDblcAbnormalService //修改
{
    @Autowired
    private KyLaneDblcAbnormalMapper kyLaneDblcAbnormalMapper;

    /**
     * 查询顶 板离层测点异常信息数据项说明
     * 
     * @param kyLaneDblcAbnormalId 顶 板离层测点异常信息数据项说明主键
     * @return 顶 板离层测点异常信息数据项说明
     */
    @Override
    public KyLaneDblcAbnormal selectKyLaneDblcAbnormalByKyLaneDblcAbnormalId(String kyLaneDblcAbnormalId)
    {
        return kyLaneDblcAbnormalMapper.selectKyLaneDblcAbnormalByKyLaneDblcAbnormalId(kyLaneDblcAbnormalId);
    }

    /**
     * 查询顶 板离层测点异常信息数据项说明列表
     * 
     * @param kyLaneDblcAbnormal 顶 板离层测点异常信息数据项说明
     * @return 顶 板离层测点异常信息数据项说明
     */
    @Override
    public List<KyLaneDblcAbnormal> selectKyLaneDblcAbnormalList(KyLaneDblcAbnormal kyLaneDblcAbnormal)
    {
        return kyLaneDblcAbnormalMapper.selectKyLaneDblcAbnormalList(kyLaneDblcAbnormal);
    }

    /**
     * 新增顶 板离层测点异常信息数据项说明
     * 
     * @param kyLaneDblcAbnormal 顶 板离层测点异常信息数据项说明
     * @return 结果
     */
    @Override
    public int insertKyLaneDblcAbnormal(KyLaneDblcAbnormal kyLaneDblcAbnormal)
    {
        return kyLaneDblcAbnormalMapper.insertKyLaneDblcAbnormal(kyLaneDblcAbnormal);
    }

    /**
     * 修改顶 板离层测点异常信息数据项说明
     * 
     * @param kyLaneDblcAbnormal 顶 板离层测点异常信息数据项说明
     * @return 结果
     */
    @Override
    public int updateKyLaneDblcAbnormal(KyLaneDblcAbnormal kyLaneDblcAbnormal)
    {
        return kyLaneDblcAbnormalMapper.updateKyLaneDblcAbnormal(kyLaneDblcAbnormal);
    }

    /**
     * 批量删除顶 板离层测点异常信息数据项说明
     * 
     * @param kyLaneDblcAbnormalIds 需要删除的顶 板离层测点异常信息数据项说明主键
     * @return 结果
     */
    @Override
    public int deleteKyLaneDblcAbnormalByKyLaneDblcAbnormalIds(String[] kyLaneDblcAbnormalIds)
    {
        return kyLaneDblcAbnormalMapper.deleteKyLaneDblcAbnormalByKyLaneDblcAbnormalIds(kyLaneDblcAbnormalIds);
    }

    /**
     * 删除顶 板离层测点异常信息数据项说明信息
     * 
     * @param kyLaneDblcAbnormalId 顶 板离层测点异常信息数据项说明主键
     * @return 结果
     */
    @Override
    public int deleteKyLaneDblcAbnormalByKyLaneDblcAbnormalId(String kyLaneDblcAbnormalId)
    {
        return kyLaneDblcAbnormalMapper.deleteKyLaneDblcAbnormalByKyLaneDblcAbnormalId(kyLaneDblcAbnormalId);
    }

    @Override
    public List<String> getDblcValueList() {
        List<DblcAbnormalDto> list = kyLaneDblcAbnormalMapper.getDblcValueList();
        if (list == null || list.isEmpty()) {
            //list  为空
            List<DblcAbnormalDto> defaultList = new ArrayList<>();
            for (int i = 0; i < 7; i++) {
                DblcAbnormalDto abnormalCountDto = new DblcAbnormalDto();
                abnormalCountDto.setAbnormalCount(0);
                defaultList.add(abnormalCountDto);
            }
            List<String> collect = defaultList.stream().map(objInList -> {
                String abnormalCount = String.valueOf(objInList.getAbnormalCount());
                return abnormalCount;
            }).collect(Collectors.toList());
            return collect;
        } else {
            List<DblcAbnormalDto> resultList = new ArrayList<>(list);
            while (resultList.size() < 7) {
                DblcAbnormalDto abnormalCountDto = new DblcAbnormalDto();
                resultList.add(abnormalCountDto);
            }

            List<String> collect = resultList.stream().map(objInList -> {
                String abnormalCount = String.valueOf(objInList.getAbnormalCount());
                return abnormalCount;
            }).collect(Collectors.toList());
            return collect;
        }

//        return kyLaneDblcAbnormalMapper.getDblcValueList();
    }
}
